package h0903;

import java.util.Arrays;
import java.util.Comparator;
/**
  * @description 最大数
  * @author 不知名帅哥
  * @date 2024/9/3 23:50
  * @version 1.0
*/
public class MaxNumber {
    public static void main(String[] args) {
        int[] nums={3,30,34,5,9};
        System.out.println(largestNumber(nums));
    }

    public static String largestNumber(int[] nums) {
        String[] strings=new String[nums.length];
        for (int i = 0; i < nums.length; i++) {
            strings[i]=String.valueOf(nums[i]);
        }
        Arrays.sort(strings, (o1, o2) -> {
            String a=o1+o2;
            String b=o2+o1;
            return b.compareTo(a);
        });
        StringBuilder builder = new StringBuilder();
        for (String s : strings) {
            builder.append(s);
        }
        return builder.toString();
    }
}
